#if 1
#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 7;
const int INF = 0x3f3f3f3f;
int n, m, s, t;
vector<int> adj[N];
int diss[N], dist[N];
bool viss[N], vist[N];
bool g[N][N];
// void dfs(int u, int dep, int dis[], bool vis[]) {
//   if (vis[u]) return;
//   vis[u] = true;
//   dis[u] = dep;
//   for (auto v : adj[u]) {
//     dfs(v, dep + 1, dis, vis);
//   }
// }

void bfs(int u, int dis[], bool vis[]) {
  queue<pair<int, int> > q;
  q.emplace(u, 0);
  while (q.size()) {
    auto [u, dep] = q.front();
    q.pop();
    for (auto el : adj[u]) {
      if (vis[el]) continue;
      vis[el] = true;
      if (dis[el] == INF) dis[el] = dep + 1;
      q.emplace(el, dis[el]);
    }
  }
}
int main() {
  cin >> n >> m >> s >> t;
  memset(diss, 0x3f, sizeof(diss));
  memset(dist, 0x3f, sizeof(dist));
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    g[u][v] = g[v][u] = true;
  }
  diss[s] = dist[t] = 0;
  bfs(s, diss, viss);
  bfs(t, dist, vist);

  if (diss[t] == INF) {
    cout << "0\n";
    return 0;
  }

  // for (int i = 0; i <= n; ++i) cout << diss[i] << ' ';
  // cout << endl;
  // for (int i = 0; i <= n; ++i) cout << dist[i] << ' ';
  // cout << endl;

  int total = diss[t];
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if (g[i][j]) continue;
      if (diss[i] + dist[j] + 1 >= total && diss[j] + dist[i] + 1 >= total) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

#else

#include <bits/stdc++.h>
using namespace std;
int n, m, s, t;
const int maxn = 1000 + 7;
int g[maxn][maxn];

int main() {
  cin >> n >> m >> s >> t;

  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    g[u][v] = g[v][u] = 1;
  }
}

#endif
